/*
 * @Descripttion: 
 * @Author: junhuafly
 * @Date: 2020-03-06 15:56:45
 * @LastEditors: junhuafly
 * @Email: junhuafly@163.com
 * @LastEditTime: 2020-03-09 15:08:21
 */

import { orderAPI } from "../../../../api/index"

import {
  returnStatus,
} from './../../../../utils/index'

// pages/mine/order/logistics/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    state: ['在途', '揽收', '疑难', '已签收', '退签', '派件', '退回'],
    stateIcoMap: [
        '已下单', { 0: '/pages/images/icon/logistics/order_logistics_Placeorder_n@2x.png', 1: '/pages/images/icon/logistics/order_logistics_Placeorder_s@2x.png' }
      ,
        '已发货', { 0: '/pages/images/icon/logistics/order_logistics_shipped_n@2x.png', 1: '/pages/images/icon/logistics/order_logistics_shipped_s@2x.png' }
      ,
        '已揽件', { 0: '/pages/images/icon/logistics/order_logistics_receipt_n@2x.png', 1: '/pages/images/icon/logistics/order_logistics_receipt_s@2x.png' }
      ,
        '运输中', { 0: '/pages/images/icon/logistics/order_logistics_transport_n@2x.png', 1: '/pages/images/icon/logistics/order_logistics_transport_s@2x.png' }
      ,
        '派件中', { 0: '/pages/images/icon/logistics/order_logistics_pie_n@2x.png', 1: '/pages/images/icon/logistics/order_logistics_pie_s@2x.png' }
      ,
        '待取件', { 0: '/pages/images/icon/logistics/order_logistics_fetched_n@2x.png', 1: '/pages/images/icon/logistics/order_logistics_fetched_s@2x.png' }
      ,
        '已签收', { 1: '/pages/images/icon/logistics/order_logistics_signed_s@2x.png' }
      ,
        "null", { 1: '/pages/images/icon/logistics/order_logistics_address_icon@2x.png' }
      
    ],
    status : { 3: 3, 0: 1, 5: 2 },
    hur_status:[{
      key:'已发货',
      val:'-1'
    },{
      key:'运输中',
      val:0
    },{
      key:'派件中',
      val:5
    },{
      key:'已签收',
      val:3
    }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function ({orderId,expressCode}) {
    // 获取物流信息
    orderAPI.queryOrderLogistics({orderId,expressCode}).then(async res=>{
      const infos = await returnStatus(res)
      if(infos){
        this.setData({
          logistics:infos.data.unshift(),
          infos,
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})